hast-util-from-string
Set the plain-text value of a hast node.
This is like the DOMs Node#textContent
setter.
The given node is returned.
Install
npm:
npm install hast-util-from-string
Use
var h = require('hastscript')
var fromString = require('hast-util-from-string')
fromString(h('p'), 'Alpha')
fromString(h('div', [h('b', 'Bold'), ' and ', h('i', 'italic'), '.']), 'Charlie')
API
fromString(node[, value])
If node
is a text node (has a value
property), set that to the given
value
or an empty string.
If node
is a parent node (has children
), replace them with a text node
whose data is set to the given value
, or if value
is not given, remove
all its children.
Contribute
See contributing.md
in rehypejs/.github
for ways
to get started.
See support.md
for ways to get help.
This project has a code of conduct.
By interacting with this repository, organization, or community you agree to
abide by its terms.
License
MIT © Titus Wormer